package com.spyz.hdfs_api;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.net.URI;

public class P3_Hdfs_api_get_1 {
    public static void main(String[] args) throws Exception {

        URI uri = new URI("hdfs://master:8020");

        Configuration conf = new Configuration();
        conf.set("dfs.replication","2");

        String user = "root";

        FileSystem fs = FileSystem.get(uri, conf,user);
        /**
         * 参数1：是否删除原始数据
         * 参数2：源文件路径
         * 参数3：目标路径
         * 参数4：本地文件校验
         */
        fs.copyToLocalFile(
                false,
                new Path("/hdfs_api/word.txt"),
                new Path("./data/get_word.txt"),
                true
        );

        fs.close();
    }
}
